<template>
  <div>
    <div class="mobile-menU" v-show="flag">
      <van-dropdown-menu active-color="#1989fa">
        <van-dropdown-item v-model="value1" :options="option1" />
      </van-dropdown-menu>
    </div>
    <Users></Users>
    <Menu></Menu>
    <router-view class="content"></router-view>
  </div>
</template>

<script>
import Menu from '@/common/Menu';
import Users from '@/common/Users';

export default {
  name: "Index",
  components: {
    Menu,
    Users
  },
  methods: {
    screenWidthJudge() {
      if(document.documentElement.clientWidth < 800) {
        this.flag = true;
      }
    }
  },
  data() {
    return {
      flag: false,
      value1: 0,
      option1: [
        { text: '···', value: 0 },
        { text: '🌫', value: 1 },
      ],
    };
  },
  mounted() {
    this.screenWidthJudge()
  },
  watch: {
    '$store.state.screenWidth': function (val) {        //监听屏幕宽度变化
      if(val < 800) {
        this.flag = true
      }
      else {
        this.flag = false
      }
    },
    'value1': function (val) {
      if(val == 1) {
        window.location.href = '/user'
      }
    }
  }
}
</script>

<style lang="scss" scoped>
@import "../assets/style/common";

@media screen and (min-width: 800px) {
  .content {
    width: 82%;
    position: absolute;
    right: 0;
  }
}
@media screen and (max-width: 800px) {
  .content {
    width: 100%;
    position: absolute;
    right: 0;
  }
}
@media screen and (max-width: 800px) {
  .mobile-menU {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 99;
  }
}

.content {
  height: 100%;
}

::v-deep .van-dropdown-menu {
  opacity: 0.5;
}
::v-deep .van-dropdown-menu__bar {
  background-color: #1a1a1a;
  opacity: 1;
}
::v-deep .van-dropdown-menu__title {
  color: white;
  font-size: 30px;
  width: 50px;
}
::v-deep .van-dropdown-menu__title::after {
  border: none;
}
::v-deep .van-popup--top {
  width: 50px;
}
::v-deep .van-cell {
  background-color: #1a1a1a;
  font-size: 20px;
  color: white;
}
::v-deep .van-overlay {
  background-color: rgba(0, 0, 0, 0);
}
</style>